#pragma once
#include "Client7z_global.h"
#include <QObject>
#include <QLibrary>

typedef enum ExtractERROR
{
    EXTRACT_RESULT_NO_ERROR = 0,
    EXTRACT_RESULT_EXTRACT_RESULT_FAILED = 1,
    EXTRACT_RESULT_UNSUPPORTEDMETHOD = 2,
    EXTRACT_RESULT_CRCERROR = 3,
    EXTRACT_RESULT_DATAERROR = 4,
    EXTRACT_RESULT_UNAVAILABLEERROR = 5,
    EXTRACT_RESULT_UNEXPECTEDEND = 6,
    EXTRACT_RESULT_DATAAFTEREND = 7,
    EXTRACT_RESULT_ISNOTARC = 8,
    EXTRACT_RESULT_HEADERSERROR = 9
}emExtractError;


class ICallbackServerZip
{
public:
    ICallbackServerZip()
    {
    }
    virtual ~ICallbackServerZip()
    {
    }

    /// 获取压缩文件大小
    virtual void ICallCompressFileSize(quint64 uCompressFileSize) = 0;

    /// 获取解压文件大小
    virtual void ICallExtractFileSize(quint64 uExtractFileSize) = 0;

    /// 获取压缩比例大小
    virtual void ICallCompressComplete(float floatCompressSize) = 0;

    /// 获取解压比例大小
    virtual void ICallExtractComplete(float floatExtractFileSize) = 0;

    /// 获取压缩文件名称
    virtual void ICallCompressFileName(QString strCompressFile) = 0;

    /// 获取解压文件名称
    virtual void ICallExtractFileName(QString strExtractFile) = 0;
};

class CLIENT7Z_EXPORT ServerZip:public QObject
{
    Q_OBJECT
public:
    ServerZip();
    ~ServerZip();
    enum Operation
    {
        Q7ZIP_COMPRESS = 0U,
        Q7ZIP_EXTRACT,
        Q7ZIP_SHOWLIST
    };

public:
    static ServerZip * getInstance(void);

    int Init(void);

    QString Lzma_sdk_version(void);

    int Compress(const QString &archive_name, const QStringList &compress_filelist, const QString &working_path);

    int Extract(const QString &archive_name, const QString &output_path);

    int Showfilelist(const QString &archive_name);

    void RegisterCallbackServerZip(ICallbackServerZip* callServerZip);			/// 这一步必须在调用接口之前调用

    void SetExtractError(emExtractError emError);

    const int GetExtractError();

private:
    static ServerZip * m_q7zip;
    QLibrary m_7zLib;

public:
    ICallbackServerZip* m_callbackServerZip;			/// 回调类指针
    emExtractError m_nExtractError;


};

